***********************************************************************************
***	Replication file for:                                                     	***
*** Braun, S. T. and Stuhler, J. (2024). The Economic Consequences of 			***
***	Being Widowed by War: A Life-Cycle Perspective.	     						***
***																				***
***	Journal of Public Economics                                                 ***
***   							                                                ***
*** Script:		2-mzu-71-descriptives.do						   			 	***	
*** Purpose:	Prewar differences between later war widows and non-widows,		*** 
***				MZU1971															***
***																				***
*** Tables:		1, E1															***
***	Figure:		---																***
***********************************************************************************

*** Load data
use "$widowsdir/processed/mzu1971-edit.dta", clear

********************************************************************************
*** Sample restrictions
********************************************************************************

** Keep only observation without missing covariates (i.e., corresponding to regression sample)
drop if occ_cat10_1939 == .
drop if years_schooling == . | years_education == .
drop if d_expellee == . | d_SBZ == .

** Keep only observations from baseline sample
keep if sample_baseline == 1

********************************************************************************
*** Table 1: Prewar differences between later war widows and non-widows
********************************************************************************

** Generate variables with more "telling" variable names for employment, occupational status 
** and sector of employment in 1939

gen d_employed_market_1939 = d_status_1939_cat1 

tab occ_cat10_1939, gen(d_occ_cat10_1939_cat)

gen d_selfemployed_1939 	= d_occ_cat10_1939_cat2
gen d_farmer_1939 			= d_occ_cat10_1939_cat3
gen d_civilservant_1939		= d_occ_cat10_1939_cat4
gen d_whitecollar_1939		= d_occ_cat10_1939_cat5 
gen d_bluecollar_1939		= d_occ_cat10_1939_cat6
gen d_apprentices_1939		= d_occ_cat10_1939_cat7
gen d_helping_family_1939	= d_occ_cat10_1939_cat8
gen d_unemployed_1939		= d_occ_cat10_1939_cat9
gen d_out_of_lf_1939		= d_occ_cat10_1939_cat10
gen d_in_education_1939		= d_occ_cat10_1939_cat1 

tab sector_cat6_1939, gen(d_sector_cat6_1939_cat)

gen d_unkown_1939			= d_sector_cat6_1939_cat1
gen d_agriculture_1939		= d_sector_cat6_1939_cat2
gen d_industry_1939			= d_sector_cat6_1939_cat3
gen d_construction_1939		= d_sector_cat6_1939_cat4
gen d_trade_1939			= d_sector_cat6_1939_cat5
gen d_finance_1939			= d_sector_cat6_1939_cat6
gen d_service_1939			= d_sector_cat6_1939_cat7

** Set Excel file for export
putexcel set "$widowsdir/results/tables/descriptives.xlsx", replace sheet(table-1) 

** Descriptive statistics by widowhood status

local characteristics "birth_year d_houseowner_1939 years_education years_schooling siblings d_expellee d_SBZ d_employed_1939 d_employed_market_1939 d_selfemployed_1939 d_farmer_1939 d_civilservant_1939 d_whitecollar_1939 d_bluecollar_1939 d_apprentices_1939 d_helping_family_1939 d_in_education_1939 d_unemployed_1939 d_out_of_lf_1939 d_agriculture_1939 d_industry_1939 d_construction_1939 d_trade_1939 d_finance_1939 d_service_1939 d_unkown_1939"

matrix C = J(26,6,.)
matrix list C
local j = 1
foreach characteristic in `characteristics'{
	ttest `characteristic', by(d_warwidow)
	matrix C[`j',1] = r(mu_2), r(sd_2), r(mu_1), r(sd_1), r(t), (r(mu_2) - r(mu_1)) / ((r(sd_2)^2 + r(sd_1)^2)/2)^0.5
	local ++j
}

matrix rownames C = `characteristics'
matrix colnames C = mu_T sd_T mu_C sd_C t normdiff

matrix list C

putexcel A1 = matrix(C), names 

matrix drop C

********************************************************************************
*** Table E1: Predicting war widowhood status in the Microcensus 1971
********************************************************************************

** Predict Widowhood status

putexcel set "$widowsdir/results/tables/descriptives.xlsx", modify sheet(table-E1) 
putexcel B1 = "Dep:"
putexcel C1 = "Warwidow (0/1)"
putexcel A2 = "R2"
putexcel A3 = "Birth year"
putexcel B3 = "yes"
putexcel C3 = "yes"
putexcel D3 = "yes"
putexcel E3 = "yes"
putexcel A4 = "Socio-demographic characteristics"
putexcel B4 = "no"
putexcel C4 = "yes"
putexcel D4 = "yes"
putexcel E4 = "yes"
putexcel A5 = "Employment and occupational status"
putexcel B5 = "no"
putexcel C5 = "no"
putexcel D5 = "yes"
putexcel E5 = "yes"
putexcel A6 = "Sector of employment"
putexcel B6 = "no"
putexcel C6 = "no"
putexcel D6 = "no"
putexcel E6 = "yes"

reg d_warwidow i.birth_year, vce(cluster district_no)
putexcel B2 =  matrix(e(r2)) 

reg d_warwidow i.birth_year i.years_education d_houseowner_1939 d_expellee d_SBZ siblings, vce(cluster district_no)
putexcel C2 =  matrix(e(r2)) 

reg d_warwidow i.birth_year i.years_education d_houseowner_1939 d_expellee d_SBZ siblings d_selfemployed_1939 d_farmer_1939 d_civilservant_1939 d_whitecollar_1939 d_bluecollar_1939 d_apprentices_1939 d_helping_family_1939 d_unemployed_1939 d_out_of_lf_1939, vce(cluster district_no)
putexcel D2 =  matrix(e(r2))

reg d_warwidow i.birth_year i.years_education d_houseowner_1939 d_expellee d_SBZ siblings d_selfemployed_1939 d_farmer_1939 d_civilservant_1939 d_whitecollar_1939 d_bluecollar_1939 d_apprentices_1939 d_helping_family_1939 d_unemployed_1939 d_out_of_lf_1939 d_agriculture_1939 d_industry_1939 d_construction_1939 d_trade_1939 d_finance_1939 d_service_1939, vce(cluster district_no)
putexcel E2 =  matrix(e(r2))











** End of file
